package o;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window.Callback;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.appcompat.widget.ActionMenuPresenter;
import androidx.appcompat.widget.ScrollingTabContainerView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.ViewCompat;
import o.ah.c;
import o.ah.g;
import o.bd.e;

@RestrictTo({d.LIBRARY_GROUP})
public class cx implements ck {
    private Drawable ʻ;
    private Drawable ʻॱ;
    private Drawable ʼ;
    private Drawable ʽ;
    boolean ˊ;
    private ActionMenuPresenter ˊॱ;
    private int ˋ;
    private int ˋॱ;
    CharSequence ˎ;
    Toolbar ˏ;
    private boolean ˏॱ;
    private CharSequence ͺ;
    Callback ॱ;
    private CharSequence ॱˊ;
    private int ॱˎ;
    private View ॱॱ;
    private View ᐝ;

    public cx(Toolbar toolbar, boolean z) {
        this(toolbar, z, ah$h.ˎ, ah.d.ˋॱ);
    }

    public cx(Toolbar toolbar, boolean z, int i, int i2) {
        this.ˋॱ = 0;
        this.ॱˎ = 0;
        this.ˏ = toolbar;
        this.ˎ = toolbar.ˊॱ();
        this.ॱˊ = toolbar.ॱˊ();
        this.ˏॱ = this.ˎ != null;
        this.ʼ = toolbar.ॱˎ();
        cw ॱ = cw.ॱ(toolbar.getContext(), null, g.ˏ, c.ॱ, 0);
        this.ʻॱ = ॱ.ˋ(g.ॱˋ);
        if (z) {
            CharSequence ˊ = ॱ.ˊ(g.ˎ);
            if (!TextUtils.isEmpty(ˊ)) {
                ˊ(ˊ);
            }
            ˊ = ॱ.ˊ(g.ॱ);
            if (!TextUtils.isEmpty(ˊ)) {
                ˏ(ˊ);
            }
            Drawable ˋ = ॱ.ˋ(g.ʼ);
            if (ˋ != null) {
                ˏ(ˋ);
            }
            ˋ = ॱ.ˋ(g.ॱॱ);
            if (ˋ != null) {
                ˋ(ˋ);
            }
            if (this.ʼ == null && this.ʻॱ != null) {
                ॱ(this.ʻॱ);
            }
            ॱ(ॱ.ॱ(g.ˊ, 0));
            int ॱॱ = ॱ.ॱॱ(g.ͺ, 0);
            if (ॱॱ != 0) {
                ॱ(LayoutInflater.from(this.ˏ.getContext()).inflate(ॱॱ, this.ˏ, false));
                ॱ(this.ˋ | 16);
            }
            ॱॱ = ॱ.ʼ(g.ˋ, 0);
            if (ॱॱ > 0) {
                LayoutParams layoutParams = this.ˏ.getLayoutParams();
                layoutParams.height = ॱॱ;
                this.ˏ.setLayoutParams(layoutParams);
            }
            ॱॱ = ॱ.ˊ(g.ˊॱ, -1);
            int ˊ2 = ॱ.ˊ(g.ʻॱ, -1);
            if (ॱॱ >= 0 || ˊ2 >= 0) {
                this.ˏ.setContentInsetsRelative(Math.max(ॱॱ, 0), Math.max(ˊ2, 0));
            }
            ॱॱ = ॱ.ॱॱ(g.ᐝ, 0);
            if (ॱॱ != 0) {
                this.ˏ.setTitleTextAppearance(this.ˏ.getContext(), ॱॱ);
            }
            ॱॱ = ॱ.ॱॱ(g.ʻ, 0);
            if (ॱॱ != 0) {
                this.ˏ.setSubtitleTextAppearance(this.ˏ.getContext(), ॱॱ);
            }
            int ॱॱ2 = ॱ.ॱॱ(g.ॱᐝ, 0);
            if (ॱॱ2 != 0) {
                this.ˏ.setPopupTheme(ॱॱ2);
            }
        } else {
            this.ˋ = ᐝॱ();
        }
        ॱ.ॱ();
        ˋ(i);
        this.ͺ = this.ˏ.ͺ();
        this.ˏ.setNavigationOnClickListener(new OnClickListener(this) {
            final /* synthetic */ cx ˊ;
            final bg ॱ = new bg(this.ˊ.ˏ.getContext(), 0, 16908332, 0, 0, this.ˊ.ˎ);

            {
                this.ˊ = r8;
            }

            public void onClick(View view) {
                if (this.ˊ.ॱ != null && this.ˊ.ˊ) {
                    this.ˊ.ॱ.onMenuItemSelected(0, this.ॱ);
                }
            }
        });
    }

    public void ˋ(int i) {
        if (i != this.ॱˎ) {
            this.ॱˎ = i;
            if (TextUtils.isEmpty(this.ˏ.ͺ())) {
                ʽ(this.ॱˎ);
            }
        }
    }

    private int ᐝॱ() {
        if (this.ˏ.ॱˎ() == null) {
            return 11;
        }
        this.ʻॱ = this.ˏ.ॱˎ();
        return 15;
    }

    public ViewGroup ˏ() {
        return this.ˏ;
    }

    public Context ˎ() {
        return this.ˏ.getContext();
    }

    public boolean ॱ() {
        return this.ˏ.ˏॱ();
    }

    public void ˊ() {
        this.ˏ.ˋॱ();
    }

    public void ˎ(Callback callback) {
        this.ॱ = callback;
    }

    public void ˋ(CharSequence charSequence) {
        if (!this.ˏॱ) {
            ˎ(charSequence);
        }
    }

    public void ˊ(CharSequence charSequence) {
        this.ˏॱ = true;
        ˎ(charSequence);
    }

    private void ˎ(CharSequence charSequence) {
        this.ˎ = charSequence;
        if ((this.ˋ & 8) != 0) {
            this.ˏ.setTitle(charSequence);
        }
    }

    public void ˏ(CharSequence charSequence) {
        this.ॱˊ = charSequence;
        if ((this.ˋ & 8) != 0) {
            this.ˏ.setSubtitle(charSequence);
        }
    }

    public void ˋ() {
        Log.i("ToolbarWidgetWrapper", "Progress display unsupported");
    }

    public void ʼ() {
        Log.i("ToolbarWidgetWrapper", "Progress display unsupported");
    }

    public void ˊ(int i) {
        ˋ(i != 0 ? ar.ˋ(ˎ(), i) : null);
    }

    public void ˋ(Drawable drawable) {
        this.ʻ = drawable;
        ʻॱ();
    }

    public void ˏ(int i) {
        ˏ(i != 0 ? ar.ˋ(ˎ(), i) : null);
    }

    public void ˏ(Drawable drawable) {
        this.ʽ = drawable;
        ʻॱ();
    }

    private void ʻॱ() {
        Drawable drawable = null;
        if ((this.ˋ & 2) != 0) {
            drawable = (this.ˋ & 1) != 0 ? this.ʽ != null ? this.ʽ : this.ʻ : this.ʻ;
        }
        this.ˏ.setLogo(drawable);
    }

    public boolean ᐝ() {
        return this.ˏ.ˎ();
    }

    public boolean ॱॱ() {
        return this.ˏ.ॱॱ();
    }

    public boolean ʽ() {
        return this.ˏ.ʽ();
    }

    public boolean ʻ() {
        return this.ˏ.ʼ();
    }

    public boolean ˊॱ() {
        return this.ˏ.ʻ();
    }

    public void ͺ() {
        this.ˊ = true;
    }

    public void ॱ(Menu menu, bn.d dVar) {
        if (this.ˊॱ == null) {
            this.ˊॱ = new ActionMenuPresenter(this.ˏ.getContext());
            this.ˊॱ.ॱ(ah$i.ॱॱ);
        }
        this.ˊॱ.ˎ(dVar);
        this.ˏ.setMenu((bd) menu, this.ˊॱ);
    }

    public void ˏॱ() {
        this.ˏ.ᐝ();
    }

    public int ˋॱ() {
        return this.ˋ;
    }

    public void ॱ(int i) {
        int i2 = this.ˋ ^ i;
        this.ˋ = i;
        if (i2 != 0) {
            if ((i2 & 4) != 0) {
                if ((i & 4) != 0) {
                    ॱˋ();
                }
                ॱᐝ();
            }
            if ((i2 & 3) != 0) {
                ʻॱ();
            }
            if ((i2 & 8) != 0) {
                if ((i & 8) != 0) {
                    this.ˏ.setTitle(this.ˎ);
                    this.ˏ.setSubtitle(this.ॱˊ);
                } else {
                    this.ˏ.setTitle(null);
                    this.ˏ.setSubtitle(null);
                }
            }
            if ((i2 & 16) != 0 && this.ॱॱ != null) {
                if ((i & 16) != 0) {
                    this.ˏ.addView(this.ॱॱ);
                } else {
                    this.ˏ.removeView(this.ॱॱ);
                }
            }
        }
    }

    public void ˊ(ScrollingTabContainerView scrollingTabContainerView) {
        if (this.ᐝ != null && this.ᐝ.getParent() == this.ˏ) {
            this.ˏ.removeView(this.ᐝ);
        }
        this.ᐝ = scrollingTabContainerView;
        if (scrollingTabContainerView != null && this.ˋॱ == 2) {
            this.ˏ.addView(this.ᐝ, 0);
            Toolbar.LayoutParams layoutParams = (Toolbar.LayoutParams) this.ᐝ.getLayoutParams();
            layoutParams.width = -2;
            layoutParams.height = -2;
            layoutParams.ॱ = 8388691;
            scrollingTabContainerView.setAllowCollapse(true);
        }
    }

    public void ˊ(boolean z) {
        this.ˏ.setCollapsible(z);
    }

    public void ॱ(boolean z) {
    }

    public int ॱˊ() {
        return this.ˋॱ;
    }

    public void ॱ(View view) {
        if (!(this.ॱॱ == null || (this.ˋ & 16) == 0)) {
            this.ˏ.removeView(this.ॱॱ);
        }
        this.ॱॱ = view;
        if (view != null && (this.ˋ & 16) != 0) {
            this.ˏ.addView(this.ॱॱ);
        }
    }

    public ic ˏ(final int i, long j) {
        return ViewCompat.ˏॱ(this.ˏ).ˏ(i == 0 ? 1.0f : 0.0f).ˏ(j).ॱ(new id(this) {
            private boolean ˊ = false;
            final /* synthetic */ cx ˎ;

            public void ˏ(View view) {
                this.ˎ.ˏ.setVisibility(0);
            }

            public void ˎ(View view) {
                if (!this.ˊ) {
                    this.ˎ.ˏ.setVisibility(i);
                }
            }

            public void ˋ(View view) {
                this.ˊ = true;
            }
        });
    }

    public void ॱ(Drawable drawable) {
        this.ʼ = drawable;
        ॱᐝ();
    }

    private void ॱᐝ() {
        if ((this.ˋ & 4) != 0) {
            this.ˏ.setNavigationIcon(this.ʼ != null ? this.ʼ : this.ʻॱ);
        } else {
            this.ˏ.setNavigationIcon(null);
        }
    }

    public void ॱ(CharSequence charSequence) {
        this.ͺ = charSequence;
        ॱˋ();
    }

    public void ʽ(int i) {
        ॱ(i == 0 ? null : ˎ().getString(i));
    }

    private void ॱˋ() {
        if ((this.ˋ & 4) == 0) {
            return;
        }
        if (TextUtils.isEmpty(this.ͺ)) {
            this.ˏ.setNavigationContentDescription(this.ॱˎ);
        } else {
            this.ˏ.setNavigationContentDescription(this.ͺ);
        }
    }

    public void ˎ(int i) {
        this.ˏ.setVisibility(i);
    }

    public void ˎ(bn.d dVar, e eVar) {
        this.ˏ.setMenuCallbacks(dVar, eVar);
    }

    public Menu ॱˎ() {
        return this.ˏ.ॱᐝ();
    }
}
